package com.mall.db.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mall.db.mapper.PmsMemberPriceMapper;
import com.mall.pojo.PmsMemberPrice;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class PmsMemberPriceApiAmpl implements PmsMemberPriceApi {

    @Autowired
    private PmsMemberPriceMapper pmsMemberPriceMapper;

    //创建商品(八接口之一)
    @Override
    public void create(List<PmsMemberPrice> memberPriceList) {
        if (memberPriceList != null) {
            for (PmsMemberPrice pmsMemberPrice : memberPriceList) {
                pmsMemberPriceMapper.insert(pmsMemberPrice);
            }
        }
    }

    //更新商品 更新八张表之一
    @Override
    public void update(List<PmsMemberPrice> memberPriceList) {
        if(memberPriceList !=null){
            for (PmsMemberPrice pmsMemberPrice : memberPriceList) {
                pmsMemberPriceMapper.updateById(pmsMemberPrice);
            }
        }
    }


    @Override
    public List<PmsMemberPrice> selectById(Integer id) {
        LambdaQueryWrapper<PmsMemberPrice> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(PmsMemberPrice::getProductId, id);
        return pmsMemberPriceMapper.selectList(wrapper);
    }
}
